UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'fhnK0QaybfEmgxlQ0m+GRO3NVq0mHlHl8+GoNIl+KKA=' 
WHERE 
  key_id = '7f66a14f14abb60fd638e32c8fcabb5ee630e4cd69ce9d145da252e4f9451629' 
  AND (
    token = 'fhnK0QaybfEmgxlQ0m+GRO3NVq0mHlHl8+GoNIl+KKA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00035