UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'E5tB5nx3qdry02sda+LSQT2fAM4BAU6z3rDFgLo+Bho=' 
WHERE 
  key_id = '7d1aee06d53beb1cfec4dab216153dcab5942ed34551d114e8827a41f20c4d52' 
  AND (
    token = 'E5tB5nx3qdry02sda+LSQT2fAM4BAU6z3rDFgLo+Bho=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00024