UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'JNXvF4wvIKQ8xKL86Vn/sBsbGGvxheLoWMIzWasOgOs=' 
WHERE 
  key_id = '5d95c640b14d19140bde81896f30174bef4ee0ee27c392a574036c507c2bfa83' 
  AND (
    token = 'JNXvF4wvIKQ8xKL86Vn/sBsbGGvxheLoWMIzWasOgOs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00030