UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'w2jPNXYv0YieneZEjSz8bO8IdNfSQ0HKJOx5DANpEs8='
WHERE
key_id = 'caf7685abb8e15a4fab6c90070c071e2d03632d1c5a90c04da7a4728d0e2ee51'
AND (
token = 'w2jPNXYv0YieneZEjSz8bO8IdNfSQ0HKJOx5DANpEs8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)